<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="/css/style.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        a{
            color: chartreuse;
        }
    </style>
</head>

<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">工具箱</a></li>
    </ul>
    </div>

    <div style="text-align: center;"><a href="/role/toAddRole" >添加</a></div>
    <table border="1" style="margin: 0 auto;text-align: center;" align="center;">
        <tr>
            <th>名称</th>
            <th>描述</th>
            <th colspan="2" >操作</th>
        </tr>

        <tr th:each="role:${rolesList}">
            <td width="30%"><span name="roleId" id="roleId" th:text="${role.rolename}"></span></td>
            <td width="30%"><span name="description" id="description" th:text="${role.description}"></span></td>
            <td width="20%"><a th:href="@{/role/toUpdateRole(id=${role.id})}">修改</a></td>
            <td width="20%"><a th:href="@{/role/deleteRole(id=${role.id})}" >删除</a></td>
        </tr>
    </table>

</body>
</html>
<script src="/js/jquery.js"></script>
<script>

    function findRoleMenuByRid(roleId){
        if (roleId==null){
            return ;
        }
        $("input[name=menuId]").attr("checked",false);
        $.ajax({
            //请求的url
            url: "/role/findRoleMenuByRid",
            //请求的参数
            data: {"roleId":roleId},
            //请求的方式
            type: "post",
            //预期的返回类型
            dataType: "json",
            //
            success: function (data) {
                if (data.status==200){
                    var menuList=data.obj;
                    for (let i = 0; i < menuList.length; i++) {
                        let menu=menuList[i];
                        $("#chk_"+menu.id).attr("checked","checked");
                    }
                }
            }
        })

    }

</script>